package Sequence.sequence.Card;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

public class Cardlist {
    public static final String[] SUIT={"♥","♣","♦","♠"};

    
    //存放牌
    public  List<Card> cards(){
        List<Card> list=new ArrayList<>(52);
        for (int i=0;i<SUIT.length;i++){
            for (int j = 1; j <=13 ; j++) {
                int rank=j;
                String suit=SUIT[i];
                Card card=new Card(j,suit);
                list.add(card);
            }
        }
        return list;
    }
    //打乱牌
    public List<Card> swap(List<Card> list){
        for (int i = list.size()-1; i >0; i--) {
            Random r=new Random();
            int index=r.nextInt(i);
            Card card=list.get(i);
            list.set(i,list.get(index));
            list.set(index, card);
        }
        return list;
    }
    public List<List<Card>> getCard(List<Card> list){
        List<List<Card>> person=new ArrayList<>();
        List<Card> person1=new ArrayList<>();
        List<Card> person2=new ArrayList<>();
        List<Card> person3=new ArrayList<>();

        person.add(person1);
        person.add(person2);
        person.add(person3);

        for (int i = 0; i <5 ; i++) {
            for (int j = 0; j <3 ; j++) {
                Card card=list.remove(0);
                person.get(j).add(card);
            }
        }
        return person;

    }

}
